package com.lin.filter;

import com.lin.pojo.User;
import com.lin.util.Constant;

import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SysFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;
        User session_name = (User) request.getSession().getAttribute(Constant.SESSION_NAME);
        if (null == session_name){
//            response.sendRedirect("login.jsp");
            response.sendRedirect("/smbms/error.jsp");
        }
        filterChain.doFilter(req,resp);
    }

    public void destroy() {

    }
}
